/**
 * @package Component Metromap for Joomla! 1.5
 * @version $Id: metromap_fns.js 4 2010-08-17 13:58:48Z batyrkin $
 * @author Batyrkin Anton
 * @copyright (C) 2010- Batyrkin Anton
 * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 **/

function metromap_init(){
	for (stat in mapdata_stations){
		station=mapdata_stations[stat];
		metromap_showpoint(station.xs,station.ys,station.id,station.name);
	}
}

function setst(id){
	if (mode == 1){
		sel = document.getElementById('stationid');
		sel.value = id;
		document.MetromapForm.submit();
	}else
		document.location=id;
}

function metromap_showpoint(x,y,id,name){
	img = document.getElementById('mapimg');
	xx = img.offsetLeft;
	yy = img.offsetTop;
	nx=x+xx;
	ny=y+yy;
	body = document.getElementsByTagName('body')[0];
	var el = document.createElement("DIV");
	el.innerHTML = '<img src="/media/com_metromap/marker.gif" width="11" height="11" title="'+name+'" onclick="setst(\''+id+'\')">';
	el.style.position = 'absolute';
	el.style.top = ny+'px';
	el.style.left = nx+'px';
	el.style.display = 'block';
	el.style.cursor = 'pointer';
	el.style.zIindex = '10000';
	body.appendChild(el);
}

if(window.addEventListener){ // Mozilla, Netscape, Firefox
    window.addEventListener("load", function(){ metromap_init();}, false);
} else { // IE
    window.attachEvent("onload", function(){ metromap_init();});
}